﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Polymorphisme
{
    class Program
    {
        static void Main(string[] args)
        {
            ClasseFille objfF1 = new ClasseFille();
            ClasseFille objF2 = new ClasseFille();
            objfF1.f(5);
            Console.WriteLine("objF1.f(5) : X = " + objfF1.x);
            objfF1.g(5);
            Console.WriteLine("objF1.g(5) : X = " + objfF1.x);
            ClasseMere[] objTM = new ClasseMere[1];
            objTM[0] = objF2;
            objTM[0].f(5);
            Console.WriteLine("objTM[0].f(5) : X = " + objTM[0].x);
            objTM[0].g(5);
            Console.WriteLine("objTM[0].g(5) : X = " + objTM[0].x);
        }
    }
    class ClasseMere
    {
        public int x = 10;
        public virtual void f(int a)
        { x += a; }
        public virtual void g(int a)
        { x += a * 10; }
    }
    class ClasseFille : ClasseMere
    {
        public override void f(int a) // redéfinition
        {
            x *= a;
        }
        public new void g(int a) // surcharge de g
        {
            x *= a * 10;
        }
    }
}
